package com.leave.dao;

import java.sql.SQLException;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import com.leave.entity.User;
import com.leave.util.JdbcUtils;

public class UserDao {
	private QueryRunner qr = new QueryRunner(JdbcUtils.getDataSource());
	
	/**
	 * 登录验证
	 * @param user
	 * @return
	 * @throws SQLException
	 */
	public User Login(User user) throws SQLException {
		String sql = "select * from user where account=? and password=? and type=?";
		Object[] obj = new Object[]{user.getAccount(),user.getPassword(),user.getType()};
		return qr.query(sql,new BeanHandler<>(User.class),obj);
	}
}
